package sivan.interceptor;

import org.apache.ibatis.plugin.*;

import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.util.Properties;

@Intercepts(value = {@Signature(type = PreparedStatement.class,
        method = "execute", args = {})})
public class MybatisInterceptor implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        Method method = invocation.getMethod();
        Object target = invocation.getTarget();
        Object[] args = invocation.getArgs();
        System.out.println("进去拦截器前面");
        Object result = invocation.proceed();
        System.out.println(result);
        return result;
    }

    @Override
    public Object plugin(Object o) {
        return Plugin.wrap(o, this);
    }

    @Override
    public void setProperties(Properties properties) {

    }
}
